package org.znxs.znagent_s.rag.tools;

import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.model.ToolContext;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;

/**
 * 适用于 ai—agent 发送邮件工具类
 */
@Slf4j
public class SendEmailTool {

    @Tool(description = "发送邮件")
    public String sendEmail(@ToolParam(description = "邮件标题") String subject, @ToolParam(description = "发送邮件内容") String content, ToolContext toolContext) {
        MailAccount account = new MailAccount();
        account.setHost("smtp.qq.com");
        account.setPort(465);
        account.setAuth(true);
        account.setUser("669583491@qq.com");
        account.setPass("ueizuvxboqlvbcde");
        account.setFrom("669583491@qq.com");
        account.setSslEnable(true);
        String to = toolContext.getContext().get("user").toString();
        MailUtil.send(account, to, subject, content, false);
        return "邮件发送成功";
    }


}
